package zzc.javaWeb.javaWebHomew.servlet;

import zzc.javaWeb.javaWebHomew.dao.homeDaoimp;
import zzc.javaWeb.javaWebHomew.pojo.LoginBean;

import java.sql.SQLException;

public class loginServlet {
    homeDaoimp userdaoimp = new homeDaoimp();
    LoginBean loginUser = new LoginBean();

    public int getLogin(String id, String password) throws SQLException {

        /**
         * 业务层 需求
         * 拿到control层传来的前端数据，id 和password 进行登录验证
         * getLogin就是实现登录模块，主要需求层，dao层
         */
        loginUser.setId(id);
        loginUser.setPassword(password);

        int flag = userdaoimp.tologinUser(loginUser);
        return flag;
    }

    public int getReg(String id, String password) throws SQLException {
        /**
         * 通过数据库查询返回的标识数来判定是否注册成功
         */
        loginUser.setId(id);
        loginUser.setPassword(password);
        int flag = userdaoimp.addloginUser(loginUser);
        return flag;
    }
}
